package cn.qyd.kaoshi;

import java.util.HashMap;

/**
 * @author 邱运铎
 * @date 2024-03-24 12:19
 */
public class Test01 {
    public static void main(String[] args) {
        String str = "BANC";
        String t = "ABC";
        System.out.println(str.substring(0,4));
        System.out.println(str.indexOf(t.charAt(0)));
        System.out.println(str.indexOf(t.charAt(1)));
        System.out.println(str.indexOf(t.charAt(2)));
        HashMap<Integer,Integer> map = new HashMap<>();
        map.put(1,2);
//        System.out.println(map);
//        map.putIfAbsent(1,3);
        map.computeIfPresent(1, (k,v) -> v+1);
        System.out.println(map);
        map.computeIfPresent(2, (k,v) -> v+1);
        System.out.println(map);
        map.computeIfAbsent(1, v -> v+1);
        System.out.println(map);
        map.computeIfAbsent(2, v -> 6);
        System.out.println(map.get(22));
    }
}
